export const intToGradeStr = (grade) => {
  switch (grade) {
    case 1:
      return '一年级'
    case 2:
      return '二年级'
    case 3:
      return '三年级'
    case 4:
      return '四年级'
    case 5:
      return '五年级'
    case 6:
      return '六年级'
    case 7:
      return '初一'
    case 8:
      return '初二'
    case 9:
      return '初三'
    case 10:
      return '高一'
    case 11:
      return '高二'
    case 12:
      return '高三'
    default:
      return '高三'
  }
}

// 选课权限
export const calculateGradeLimitLegacy = (admissionYearLimit) => {
  if (admissionYearLimit) {
    const currentYear = new Date().getFullYear()
    const grade = currentYear - Number.parseInt(admissionYearLimit) + 1
    if (grade <= 0) {
      return '所有年级'
    } else {
      return `${intToGradeStr(grade)}及以上`
    }
  } else {
    return '所有年级'
  }
}

// 选课权限
export const calculateStudentGradeLimit = (admissionYear) => {
  if (admissionYear) {
    const currentYear = new Date().getFullYear()
    const grade = currentYear - Number.parseInt(admissionYear) + 1
    if (grade <= 0) {
      return '-'
    } else {
      return `${intToGradeStr(grade)}`
    }
  } else {
    return '-'
  }
}
